{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 字典的定义和访问"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 制作以下字典:\n",
    "```\n",
    "this : 这个\n",
    "that : 那个\n",
    "these : 这些\n",
    "those : 那些\n",
    "```\n",
    "并打印`those`单词的意思"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.把以上字典扩充以下内容:\n",
    "```\n",
    "well : 好，水井\n",
    "lol : 英雄联盟，呵呵 \n",
    "```\n",
    "并打印`lol`这个单词的第二个意思"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 字典 + 列表 结构练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 以下结构中存储网站信息，请研究结构，并通过编程回答问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "d={\"sites\": [\n",
    "    { \"name\":\"菜鸟教程\" , \"url\":\"www.runoob.com\" },\n",
    "    { \"name\":\"google\" , \"url\":\"www.google.com\" },\n",
    "    { \"name\":\"微博\" , \"url\":\"www.weibo.com\" }\n",
    "]}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "打印出`d`中包含的网站个数【注意:必须通过`d`获得】"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过`d`获得`www.runoob.com`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过`d`获得`微博`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "循环`d`中所有网站，把所有网站信息按照以下格式打印出来:\n",
    "```\n",
    "网站名称: XXXX  网站地址: XXXXX\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2.以下结构中存储一个网站的不同域名信息，研究结构，编程回答问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "cainiao = {\n",
    "    \"网名\":\"runoob\",\n",
    "    \"端口\":10000,\n",
    "    \"站点地址\": {\n",
    "        \"地之一\":\"www.runoob.com\",\n",
    "        \"地址二\":\"m.runoob.com\",\n",
    "        \"地址三\":\"c.runoob.com\"\n",
    "    }\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请打印菜鸟网的第三个地址"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3.以下结构是某电话号码归属地信息，研究结构，编程回答问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "d={\n",
    "    \"ApiName\": \"mobile\",\n",
    "    \"ErrorCode\": 0,\n",
    "    \"ErrorReason\": \"no\",\n",
    "    \"Result\": {\n",
    "        \"province\": \"河南\",\n",
    "        \"city\": \"郑州\",\n",
    "        \"isp\": \"中国联通\",\n",
    "        \"phone_num\": \"13298186923\"\n",
    "    }\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "以如下格式打印以上字典信息:\n",
    "```\n",
    "手机号: XXXX\n",
    "归属地: 省, 市\n",
    "网络服务提供商: isp的信息\n",
    "```\n",
    "请注意，所有信息必须从d中获得"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4.以下结构存储天气预报信息，研究结构，并编程回答问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "code_folding": [
     5,
     16,
     22,
     54
    ]
   },
   "outputs": [],
   "source": [
    "d={\n",
    "\t\"ApiName\": \"rtweather\",\n",
    "\t\"ErrorCode\": 0,\n",
    "\t\"ErrorReason\": \"no\",\n",
    "    \"结果\": {\n",
    "\t\t\"当日天气\": {\n",
    "\t\t\t\"Warning\": None,\n",
    "\t\t\t\"Warning_brief\": None,\n",
    "\t\t\t\"气温\": {\n",
    "\t\t\t\t\"摄氏\": \"24℃\",\n",
    "\t\t\t\t\"华氏\": \"75℉\"\n",
    "\t\t\t},\n",
    "\t\t\t\"Wet\": \"41%\",\n",
    "\t\t\t\"Weather\": \"晴\",\n",
    "\t\t\t\"WeatherCode\": \"w0\",\n",
    "\t\t\t\"QiYa\": \"996百帕\",\n",
    "\t\t\t\"Wind\": {\n",
    "\t\t\t\t\"Direction\": \"南风\",\n",
    "\t\t\t\t\"DirectionCode\": \"S\",\n",
    "\t\t\t\t\"Level\": \"2级\",\n",
    "\t\t\t\t\"Speed\": \"小于12km/h\"\n",
    "\t\t\t},\n",
    "\t\t\t\"Rain\": {\n",
    "\t\t\t\t\"last24h\": \"0mm\",\n",
    "\t\t\t\t\"now\": \"0.0mm\"\n",
    "\t\t\t}\n",
    "\t\t},\n",
    "\t\t\"日期\": \"05月11日(星期六)\",\n",
    "\t\t\"今天日期\": \"20190511\",\n",
    "\t\t\"星期\": \"星期六\",\n",
    "\t\t\"更新时间\": \"20:00\",\n",
    "\t\t\"城市\": {\n",
    "\t\t\t\"英文名\": \"zhengzhou\",\n",
    "\t\t\t\"城市编码\": \"101180101\",\n",
    "\t\t\t\"中文名\": \"河南-郑州\"\n",
    "\t\t},\n",
    "\n",
    "        \"24小时天气\": {\n",
    "\t\t\t\"日期_20190511\": {\n",
    "\t\t\t\t\"20:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月11日20时（星期六）\",\n",
    "\t\t\t\t\t\"Weather\": \"晴\",\n",
    "\t\t\t\t\t\"Temp\": \"23℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"3-4级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"23:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月11日23时（星期六）\",\n",
    "\t\t\t\t\t\"Weather\": \"多云\",\n",
    "\t\t\t\t\t\"Temp\": \"18℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"3-4级\"\n",
    "\t\t\t\t}\n",
    "\t\t\t},\n",
    "\t\t\t\"日期_20190512\": {\n",
    "\t\t\t\t\"02:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日02时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"多云\",\n",
    "\t\t\t\t\t\"Temp\": \"16℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"<3级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"05:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日05时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"多云\",\n",
    "\t\t\t\t\t\"Temp\": \"17℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"<3级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"08:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日08时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"多云\",\n",
    "\t\t\t\t\t\"Temp\": \"22℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"<3级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"11:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日11时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"阴\",\n",
    "\t\t\t\t\t\"Temp\": \"28℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"<3级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"14:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日14时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"阴\",\n",
    "\t\t\t\t\t\"Temp\": \"30℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"<3级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"17:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日17时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"阴\",\n",
    "\t\t\t\t\t\"Temp\": \"27℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"4-5级\"\n",
    "\t\t\t\t},\n",
    "\t\t\t\t\"20:00\": {\n",
    "\t\t\t\t\t\"Time\": \"2019年05月12日20时（星期日）\",\n",
    "\t\t\t\t\t\"Weather\": \"阴\",\n",
    "\t\t\t\t\t\"Temp\": \"26℃\",\n",
    "\t\t\t\t\t\"WindDirection\": \"西南风\",\n",
    "\t\t\t\t\t\"WindLevel\": \"3-4级\"\n",
    "\t\t\t\t}\n",
    "\t\t\t}\n",
    "\t\t}\n",
    "\t}\n",
    "}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请打印出该城市 2019年5月11日晚23:00的温度，格式如下\n",
    "```\n",
    "省-市 在2019年5月11日晚23:00的温度是 XX℃\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "河南-郑州 在2019年5月11日晚23:00的温度是 18℃\n"
     ]
    }
   ],
   "source": [
    "ct=d[\"结果\"][\"城市\"][\"中文名\"]\n",
    "temp=d[\"结果\"][\"24小时天气\"][\"日期_20190511\"]['23:00']['Temp']\n",
    "print(ct,\"在2019年5月11日晚23:00的温度是\",temp)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
